import 'package:flutter/cupertino.dart';
import 'package:flutter_application_1/models/recommend_interface.dart';
import 'package:flutter_application_1/models/user_model.dart';

class VideoList {
  late final List<VideoItem> list;
  VideoList(this.list);
  factory VideoList.fromJson(List<dynamic> list) {
    return VideoList(
      list.map((e) => VideoItem.fromJson(e)).toList(),
    );
  }
}

class VideoItem implements RecommendInterface {
  late final int id;
  late final int userId;
  late final String coverPictureUrl;
  late final String videoUrl;
  late final String title;
  late final String intro;
  late final int commentCount;
  late final int thumbUpCount;
  late final int readCount;
  late final int shareCount;
  late final int contentSeconds;
  late UserItem user;

  VideoItem({
    required this.id,
    required this.userId,
    required this.coverPictureUrl,
    required this.videoUrl,
    required this.title,
    required this.intro,
    required this.commentCount,
    required this.thumbUpCount,
    required this.readCount,
    required this.shareCount,
    required this.contentSeconds,
    required this.user,
  });

  factory VideoItem.fromJson(dynamic item) {
    return VideoItem(
      id: item["id"],
      userId: item["userId"],
      coverPictureUrl: item["coverPictureUrl"],
      videoUrl: item["videoUrl"],
      title: item["title"],
      intro: item["intro"],
      commentCount: item["commentCount"],
      thumbUpCount: item["thumbUpCount"],
      readCount: item["readCount"],
      shareCount: item["shareCount"],
      contentSeconds: item["contentSeconds"],
      user: UserItem.fromJson(item["user"]),
    );
  }
}
